import CommonApi from './common'
import { uploadFileTimeout } from '@/config/settings'

// 养护工程 /养护工程管理 /工程台账管理
class ProjectLedgerApi extends CommonApi {
    constructor() {
        super()
        this.scope = '/ms/project'
    }

    // 导入模版下载地址
    static templatePath = '/ms/quantities/template/download'

    // 导入错误结果下载地址
    static importResultPath = '/ms/quantities/error/log/download'

    // 工程量清单和计日工导出地址
    static quantitiesAndDayExportPath = '/ms/quantities/export'
    // 导出计量审批表地址
    static applicationExportPath = '/ms/project/application/export'
    // 导出计量清单汇总表
    static applicationStatisticsExportPath = '/ms/project/application/export/statistics'
    // 导出计量清单明细表
    static applicationParticularsExportPath = '/ms/project/application/export/list'

    records(data) {
        const path = this.resolvePath('/page/list')
        return this.post(path, data)
    }
    // 获取不分页的合同列表，用于获取合同下拉框
    allList(data) {
        const path = this.resolvePath('/list')
        return this.post(path, data)
    }

    // 获取所有已经锁定的项目
    getListByLock(data) {
        const path = '/ms/project/lock/list'
        return this.post(path, data)
    }

    // 名称唯一性检查
    validNameUnique(data) {
        const path = this.resolvePath('/verification')
        return this.post(path, data)
    }
    // 清单子目编码唯一性检查
    validQuantitiesUnique(data) {
        const path = '/ms/quantities/verification'
        return this.post(path, data)
    }

    saveOrUpdate(data) {
        const path = this.resolvePath('/save')
        return this.post(path, data)
    }
    // 复制合同
    copySave(data) {
        const path = this.resolvePath('/copy')
        return this.post(path, data)
    }

    detail(data) {
        const path = this.resolvePath('/detailsById')
        return this.post(path, data)
    }
    delete(data) {
        const path = this.resolvePath('/delete/batch')
        return this.post(path, data)
    }
    lock(data) {
        const path = this.resolvePath('/lock')
        return this.post(path, data)
    }

    // 章次列表
    chapterList() {
        const path = '/ms/standard-bill-quantites/chapter/list'
        return this.post(path)
    }
    // 分类列表
    classifyList() {
        const path = '/ms/standard-bill-quantites/daywork-category/list'
        return this.post(path)
    }
    // 工程量清单列表
    quantitiesList(data) {
        const path = '/ms/quantities/page/list'
        return this.post(path, data)
    }
    // 单位列表
    unitList(data) {
        const path = '/ms/unit/list'
        return this.post(path, data)
    }

    // 子类新增
    childSaveOrUpdate(data) {
        const path = '/ms/quantities/save'
        return this.post(path, data)
    }

    // 查询当前合同下的章次
    chapterListById(data) {
        const path = '/ms/bill/chapter/list'
        return this.post(path, data)
    }

    // 当前合同新增章次
    chapterAdd(data) {
        const path = '/ms/bill/chapter/save/batch'
        return this.post(path, data)
    }
    // 删除章次
    chapterDelete(data) {
        const path = '/ms/bill/chapter/delete/batch'
        return this.post(path, data)
    }
    // 已删除清单
    delList(data) {
        const path = '/ms/quantities/del/list'
        return this.post(path, data)
    }
    // 导入
    import(form) {
        const headers = { 'content-type': 'multipart/form-data' }
        const path = '/ms/quantities/import'
        return this.post(path, form, {
            headers,
            timeout: uploadFileTimeout
        })
    }
    // 子项删除
    deleteChild(data) {
        const path = '/ms/quantities/delete/batch'
        return this.post(path, data)
    }
    // 获取计日工和工程量汇总清单
    statisticsist(data) {
        const path = '/ms/quantities/statistics'
        return this.post(path, data)
    }
    // 养护工程计量申请列表
    applicationList(data) {
        const path = this.resolvePath('/application/page-list')
        return this.post(path, data)
    }
    // 养护工程计量申请基础信息保存
    applicationSave(data) {
        const path = this.resolvePath('/application/save/base')
        return this.post(path, data)
    }
    // 本期工程量列表分页查询
    currentPeriodPageList(data) {
        const path = this.resolvePath('/application/current-period/bill-quantities/page-list')
        return this.post(path, data)
    }
    // 养护工程计量申请基础信息详情
    applicationDetail(data) {
        const path = this.resolvePath('/application/detail')
        return this.post(path, data)
    }
    // 养护工程计量申请提交审批
    applicationSubmit(data) {
        const path = this.resolvePath('/application/submit')
        return this.post(path, data)
    }
    // 养护工程计量申请撤销
    applicationWithDraw(data) {
        const path = this.resolvePath('/application/revoke')
        return this.post(path, data)
    }
    // 养护工程计量申请删除
    applicationDelete(data) {
        const path = this.resolvePath('/application/del')
        return this.post(path, data)
    }
    // 养护工程计量申请审批通过
    applicationApprove(data) {
        const path = this.resolvePath('/application/approval-pass')
        return this.post(path, data)
    }
    // 养护工程计量申请审批驳回
    applicationReject(data) {
        const path = this.resolvePath('/application/approval-reject')
        return this.post(path, data)
    }
    // 护工程计量申请工程量章次/计日工分类本期计量金额合计查询
    chapterTotalCount(data) {
        const path = this.resolvePath('/application/current-period/chapter/total-amount')
        return this.post(path, data)
    }
    // 养护工程计量申请本期工程量保存
    currentPeriodSave(data) {
        const path = this.resolvePath('/application/save/current-period/bill-quantities')
        return this.post(path, data)
    }
    // 确认清单计量汇总表
    billQuantitiesCollection(data) {
        const path = this.resolvePath('/application/current-period/bill-quantities/collection')
        return this.post(path, data)
    }
    // 养护工程计量申请本期计量总金额校验
    checkTotalAmount(data) {
        const path = this.resolvePath('/application/current-period/bill-quantities/check-total-amount')
        return this.post(path, data)
    }
}

export default ProjectLedgerApi
